package demo2;

//https://ac.nowcoder.com/acm/problem/229023

import java.util.*;

public class Main{
    public static int n,m;
    public static Map<Integer,Integer> hash = new HashMap<>();
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        int mg = 0;
        for(int i = 0; i<n; i++) {
            int t = in.nextInt();
            hash.put(t, hash.getOrDefault(t,0)+1);
            mg = Math.max(mg, hash.get(t));
        }
        
        if(hash.size() > m) {
            System.out.println(-1);
            return;
        }
//         for(int i = 1; i<=mg; i++) {
//             if(check(i)) {
//                 System.out.println(i);
//                 break;
//             }
//         }
        int l = 1, r = mg;
        while(l<r) {
            int mid = l + (r-l)/2;
            if(check(mid)) r = mid;
            else l = mid+1;
        }
        System.out.println(l);
    }
    public static boolean check(int n) {
        int g = 0;
        for(int x:hash.values()) {
            g += x/n + (x%n==0?0:1);
        }
        return g<=m;
    }
}